/*
*	(*^。^*) TFrameWork License (*^。^*)
*/

/*
 *  Title :  
 *          
 *  Description :  
 *          
 *          
 *  Date : 
 *
 *  Author : DengPing
 *
 *  Modify : 
 */

using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;

namespace TFrameWork.Module.ActionEditor
{
    public class AnimationEventItemStyle : CommonEventItemStyle
    {
        public override Color eventColor => new Color(0.5f, 0.98f, 0.89f, 0.4f);

        public override int RealLenth
        {
            get
            {
                if (animationData == null || animationData.animationClip == null)
                {
                    return 1;
                }

                AnimationClip clip = animationData.animationClip;
                return (int)(clip.length * clip.frameRate);

            }
        }



        public override TrackEventBase eventData => animationData;

        private AnimationEvent animationData;
        
        public void Init(AnimationTrackStyle.CommonChildTrackBase parent, AnimationEvent data)
        {
            animationData = data;
            InitComponent(parent);
        }

        public override void ShowContent()
        {
            if (animationData.animationClip)
            {
                if (!string.IsNullOrEmpty(animationData.trackName))
                {
                    Name.text = animationData.trackName;
                }
                else
                {
                    Name.text = animationData.animationClip.name;
                }
            }
            else
            {
                Name.text = "未设置画资源";
            }
        }
    }
}
